package com.miyu.system.dao.system;

import com.alibaba.fastjson2.JSONArray;
import com.miyu.common.utils.basedao.BaseDao;
import com.miyu.system.pojo.system.SysMenu;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

/**
 * 系统菜单
 *
 * @author longm
 * @date 2022/10/04
 */
@Repository
public interface SysMenuDao extends BaseDao<SysMenu,String> {

    /**
     * 查询系统菜单
     *
     * @param menuName 菜单名称
     * @return {@link JSONArray}
     */
    public default JSONArray queryMenu(String menuName){
        JSONArray rs;
        StringBuilder sql = new StringBuilder();
        sql.append("  select * from sys_menu  ");
        if(StringUtils.isNotBlank(menuName)){
            sql.append(" where 1=1 ");
            sql.append(" and menu_name like '%").append(menuName).append("%'");
        }
        rs = this.queryJSONArrayBySql(sql.toString());

        return rs;
    }
}
